package com.waitingresult.easypoi.controller;

import com.waitingresult.common.Result;
import com.waitingresult.easypoi.entity.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

/**
 * @Author: WangShuai
 * @CreateTime: 2022-11-23  17:55
 * @Description: TODO
 * @Version: 1.0
 */
@Slf4j
@RestController
@RequestMapping("/api-feeDetaiService")
public class ExcelDemoController {
    @PostMapping(value = "select", name = "查询")
    public Result<Object> select() {
        return Result.success();
    }

    @GetMapping(value = "exportFeeDetail", name = "导出费用明细")
    public Result <Object> exportFeeDetail() {
        ArrayList<User> users = getUsers();
//        String fileName = "D:\\coding_cache\\demo" + System.currentTimeMillis() + ".xlsx";
//        EasyExcel.write(fileName, User.class)
//                .sheet("shell1")
//                .doWrite(users);
        return Result.success();
    }

    private static ArrayList<User> getUsers() {
        ArrayList<User> users = new ArrayList<>();
        int deptId = 1;
        for (int i = 0; i < 10000; i++) {
            if(i%100==0){
                deptId++;
            }
            ArrayList<String> stringList = new ArrayList<>();
            String name = "百万企业" + deptId;
            stringList.add(name);
            users.add(new User(i,deptId,"百万姓名"+i,"百万地址"+deptId));
        }
        return users;
    }
}
